package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.ArrayList;

/**
 * ClassName: CategoryMapper
 * Package: com.sky.mapper
 * Description:
 *
 * @Author 龙培
 * @Create 2025/3/1 14:29
 * @Version 1.0
 */
@Mapper
public interface CategoryMapper {
    /**
     * 更新分类信息
     * @param category
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateCategory(Category category);

    /**
     * 插入分类信息
     * @param category
     */
    @Insert("insert into category(id,type,name,sort,status,create_time,update_time,create_user,update_user) " +
            "values " +
            "(#{id},#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void insertCategory(Category category);

    /**
     * 分页查询分类信息
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> pageCategory(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 根据类型查询分类信息
     * @param type
     * @return
     */

    ArrayList<Category> pageCategoryByType(Integer type);

    /**
     * 删除分类信息
     * @param id
     */
    @Delete("delete from category where id = #{id}")
    void deleteCategory(Long id);

}
